import com.lagou.invoker.ServiceInvoke;
import com.lagou.service.MyService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;
import java.time.Instant;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class ConsumerApplication {

    public static void main(String[] args) throws IOException {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:dubbo-consumer.xml");
        MyService myService = context.getBean("myService", MyService.class);

        ExecutorService executorService = Executors.newFixedThreadPool(3);
        // 起始时间
        long startMills = Instant.now().toEpochMilli();
        while (true) {
            try {
                TimeUnit.MICROSECONDS.sleep(30);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            executorService.execute(new ServiceInvoke(myService));
        }
    }
}
